#!/usr/bin/env zx

fs.readdir('./source', async (err, files) => {
    await $`rm -rf ./element`
    await $`mkdir ./element`
    let snap = ''
    let index = 0
    for (const f of files) {
        const name = f.split('-').map(p => p.replace(p[0], p[0].toUpperCase())).join('')

        fs.readFile(`./source/${f}`, (err, data) => {
            const newData = data.toString().replaceAll(' fill="#333"', '')
            fs.writeFile(`./element/${name}`, newData)
        })

        snap += `${name.split('.')[0]}\n`
        index++
        if (index === files.length) {
            await $`rm -f ./element.snap.txt`
            fs.writeFile('./element.snap.txt', snap)
        }
    }

})